<extend name = 'layout:index'/>
<block name='content'>
<body class="">


<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" style="display: none;">
  <div class="modal-dialog modal-lg">
    
    <div class="modal-content" id="gg" style="margin-top: 185px;">

     <div class="modal-body">
       
        		
    </div>
</div>
  </div>
</div>
	<div class="table-responsive" style="margin-left:10px">
		
		<table class="table table-bordered">
			<tbody><tr>
				
			</tr>
			<tr>
				<td>用户名：<?php echo $_SESSION['users']['user_name']?>
				</td><td>会员ID：<?php echo $_SESSION['users']['user_id']?>
				</td><td>账户剩余注册积分：{$user.user_money2}
			</td></tr>
		</tbody></table>
		
		</div>

	<div style="padding-left:50px;">
	
		 <form action="__MODULE__/switch/dotransfer" method="post" onSubmit="return checkSubmit(this)" style="float:left">
		
			 <div class="form-group" style="margin-top:40px">
			 <div class="form-inline">
	    		<label for="exampleInputEmail1">转入用户名：</label>
	   			<input id="out_user_name" name="out_user_name" class="form-control"  type="text" value=''>
	  		 </div>
	  		 </div>
			 <div class="form-group" style="margin-top:40px">
			 <div class="form-inline">
	    		<label for="exampleInputEmail1">转入用户ID：</label>
	   			<input id="out_user_id" name="out_user_id" class="form-control" type="text" value=''>
	  		 </div>
	  		 </div>
			 <div class="form-group" style="margin-top:40px">
			 	<div class="form-inline">
	    		<label for="exampleInputEmail1">转入金额：&nbsp;&nbsp;&nbsp;</label>
	   		<input id="out_money" name="out_money" class="form-control"  type="text" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" value=''><p></p>
	   		<div style="color:red" >您当前剩余注册积分总额为：<span id='self_money'>{$user.user_money2}</span></div>
	   		</div>
			
	   		</div>
			<div class="form-group" style="margin-top:40px">
			 <div class="form-inline">
	    		<label for="exampleInputEmail1">安 全 码：</label>
	   			<input id="repassword" name="repassword" class="form-control" type="password" value=''>
	  		 </div>
	  		 </div>
	   		 <div class="form-group" style="margin-top:0px;padding-left:10%;">
			
				
		
	         <input  class="btn btn-primary" type='submit' data-target=".bs-example-modal-lg"  value='确定'>
   		</form>
   	</div>


	<table id='tab' width='600px' cellpadding="5px" cellspacing="0px" border='1px' color='#e7e7e7' style="float:right;margin-top:40px;text-align:center;font-size:14px;font-weight:none">
		<tr style="border-color:#e7e7e7;line-height:30px">
			<th style="text-align:center;border-color:#e7e7e7;">用户ID</th>
			<th style="text-align:center;border-color:#e7e7e7;">用户名</th>
			<th style="text-align:center;border-color:#e7e7e7;">操作</th>
		</tr>
		<foreach name='relave' item='vo'>
			<tr style="border-color:#e7e7e7;line-height:30px" >
				<td style="text-align:center;border-color:#e7e7e7;">{$vo['user_id']}</td>
				<td style="text-align:center;border-color:#e7e7e7;" >{$vo['user_name']}</td>
				<td style="text-align:center;border-color:#e7e7e7;" ><a style='color:red' class='transdelete'>删除关联</a> &nbsp;<a class='transadd'>填写</a></td>
			</tr>
		</foreach>
	</table>





		
		
<script language="javascript">
	
	var k = false;
		function checkSubmit(){
			$('.btn').attr('disabled',true);
			var self_money = $('#self_money').text();
			var out_money = $('#out_money').val();
			var money = self_money - out_money;
			if($('#out_money').val()==''){
					var txt=  "注 册 积 分 未 填";
	                     window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
	                    return false;
			}
			if(money < 0){
					var txt=  "注 册 积 分 不 足";
	                     window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
	                    return false;
			}

			$.ajax({  
	            type : 'POST',
	            url : '/home/switch/switchAjax',
	            data : {out_user_name:$('#out_user_name').val(),out_user_id:$('#out_user_id').val(),repassword:$('#repassword').val()},
	            dataType : 'html',
	            async : false,
	            success : function(str){
	                if(str==2){
	                     var txt=  "安 全 密 码 错 误";
	                        window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
	                    return false;
	                }
	                if(str==22){
	                	  var txt=  "I D 或 者 用 户 名 错 误,请 核 对 信 息";
	                        window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
	                    return false;
	                }
	                if(str==1){
	                	k = true;
	                }
	            }
		})
		return k;
	}
	//删除关联
	$('.transdelete').click(function(){
		var userid = $(this).parent().prev().prev().html();
		   $.ajax({
                    type : 'POST',
                    url : '/home/switch/transdeleteAjax',
                    data : {user_delete_id:userid},
                    dataType : 'html',
                    async : false,
                    success : function(str){                       
                         if(str == '1'){                            
                            	 var txt=  "删 除 成 功";
	                        	 window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.success);
                            	location.reload(true);
                        }else{
                               var txt=  "删 除 失 败";
	                        	 window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
                        }                        
                    }
                
                })
	})
	$('.transadd').click(function(){		
		$('#out_user_name').val($(this).parent().prev().html());
		$('#out_user_id').val($(this).parent().prev().prev().html());
	})
	
</script>

</body>
</block>